]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Chats should jump to the top of the notification queue.
authorHellyna Ng <hellyna@hellyna.com>
Tue, 4 Jan 2011 09:34:57 +0000 (17:34 +0800)
committerMarina Zhurakhinskaya <marinaz@redhat.com>
Wed, 5 Jan 2011 22:23:01 +0000 (17:23 -0500)
This is to ensure users get notified as soon as chats are received.
Notifications with critical urgency still have the highest priority.

https://bugzilla.gnome.org/show_bug.cgi?id=630934

js/ui/messageTray.js
js/ui/notificationDaemon.js
js/ui/telepathyClient.js

index 97ce07d5ac5a179ce611549d4f788c8e5fc39ce0..3593274188e44c7ed694b6d1c3107b82a597c8cd 100644 (file)
@@ -38,6 +38,17 @@ const State = {
     HIDING:  3
 };
 
+// Message tray has its custom Urgency enumeration. LOW, NORMAL and CRITICAL
+// urgency values map to the corresponding values for the notifications received
+// through the notification daemon. HIGH urgency value is used for chats received
+// through the Telepathy client.
+const Urgency = {
+    LOW: 0,
+    NORMAL: 1,
+    HIGH: 2,
+    CRITICAL: 3
+}
+
 function _fixMarkup(text, allowMarkup) {
     if (allowMarkup) {
         // Support &amp;, &quot;, &apos;, &lt; and &gt;, escape all other
@@ -225,7 +236,7 @@ function Notification(source, title, banner, params) {
 Notification.prototype = {
     _init: function(source, title, banner, params) {
         this.source = source;
-        this.urgent = false;
+        this.urgency = Urgency.NORMAL;
         this.resident = false;
         // 'transient' is a reserved keyword in JS, so we have to use an alternate variable name
         this.isTransient = false;
@@ -490,8 +501,8 @@ Notification.prototype = {
         this._updated();
     },
 
-    setUrgent: function(urgent) {
-        this.urgent = urgent;
+    setUrgency: function(urgency) {
+        this.urgency = urgency;
     },
 
     setResident: function(resident) {
@@ -1166,13 +1177,11 @@ MessageTray.prototype = {
         } else if (this._notificationQueue.indexOf(notification) < 0) {
             notification.connect('destroy',
                                  Lang.bind(this, this.removeNotification));
-
-            if (notification.urgent)
-                this._notificationQueue.unshift(notification);
-            else
-                this._notificationQueue.push(notification);
+            this._notificationQueue.push(notification);
+            this._notificationQueue.sort(function(notification1, notification2) {
+                return (notification2.urgency - notification1.urgency);
+            });
         }
-
         this._updateState();
     },
 
@@ -1508,11 +1517,11 @@ MessageTray.prototype = {
                       onCompleteScope: this
                     });
 
-        // We auto-expand urgent notifications.
+        // We auto-expand notifications with CRITICAL urgency.
         // We call _expandNotification() again on the notifications that
         // are expanded in case they were in the process of hiding and need
         // to re-expand.
-        if (this._notification.urgent || this._notification.expanded)
+        if (this._notification.urgency == Urgency.CRITICAL || this._notification.expanded)
             // This will overwrite the y tween, but leave the opacity
             // tween, and so the onComplete will remain as well.
             this._expandNotification(true);
@@ -1604,7 +1613,7 @@ MessageTray.prototype = {
    },
 
     // We use this function to grab focus when the user moves the pointer
-    // to an urgent notification that was already auto-expanded.
+    // to a notification with CRITICAL urgency that was already auto-expanded.
     _ensureNotificationFocused: function() {
         this._notification.grabFocus(false);
     },
index 0b2833df2b54c76640d3ab19b93bf513eddf0b92..7197008741b4af9ac17d5688670df5dd36ca4e0f 100644 (file)
@@ -343,8 +343,17 @@ NotificationDaemon.prototype = {
             for (let i = 0; i < actions.length - 1; i += 2)
                 notification.addButton(actions[i], actions[i + 1]);
         }
-
-        notification.setUrgent(hints.urgency == Urgency.CRITICAL);
+        switch (hints.urgency) {
+            case Urgency.LOW:
+                notification.setUrgency(MessageTray.Urgency.LOW);
+                break;
+            case Urgency.NORMAL:
+                notification.setUrgency(MessageTray.Urgency.NORMAL);
+                break;
+            case Urgency.CRITICAL:
+                notification.setUrgency(MessageTray.Urgency.CRITICAL);
+                break;
+        }
         notification.setResident(hints.resident == true);
         // 'transient' is a reserved keyword in JS, so we have to retrieve the value
         // of the 'transient' hint with hints['transient'] rather than hints.transient
index cb9a6f6142cf97bfa6942300fc3462bb80dc727f..ed8feae7d5aa33b3a41178078049e7c095ff055b 100644 (file)
@@ -476,6 +476,7 @@ Source.prototype = {
         }
 
         this._notification = new Notification(this);
+        this._notification.setUrgency(MessageTray.Urgency.HIGH);
 
         // Since we only create sources when receiving a message, this
         // is a plausible default